package init

import org.hibernate.Session
import org.hibernate.SessionFactory
import org.hibernate.boot.MetadataSources
import org.hibernate.boot.registry.StandardServiceRegistry
import org.hibernate.boot.registry.StandardServiceRegistryBuilder

object InitParams {
    val serviceRegistry: StandardServiceRegistry by lazy {
        StandardServiceRegistryBuilder().configure().build()
    }
    val sessionFactory: SessionFactory by lazy {
        MetadataSources(serviceRegistry).buildMetadata().buildSessionFactory()
    }
    val session: Session by lazy {
        println("invoke session lazy init")
        sessionFactory.openSession()
    }

}